function PlayerExists( userid )
local result = sql.QueryValue("SELECT Name FROM rleveldb WHERE userid = "..userid.."")
	if( result ) then
		return true
	else
		return false
	end

end
/*
function CreatePlayerInfo( pl , name , userid , level , credit , xp)

PlayerInfo = {}
PlayerInfo.player = pl
PlayerInfo.name = name
PlayerInfo.level = level
PlayerInfo.credit = credit
PlayerInfo.xp = xp
// Bottable

BotInfo = {}
BotInfo.player = pl
BotInfo.name = name
BotInfo.level = level
BotInfo.credit = credit
BotInfo.xp = xp
BotInfo.bot = true


	PlayerTable =  glon.encode(PlayerInfo)
	BotTable =  glon.encode(BotInfo)

if( !pl:IsBot() ) then
	PrintTable(PlayerTable)
		file.Write("RLevel/"..userid..".txt", PlayerTable)
else

		file.Write("RLevel/"..name..".txt", BotTable)
end

end
*/
function UpdatePlayer( pl , userid )

timer.Create(""..userid.."",10,0,function()
	if( PlayerExists( userid ) == true ) then
		//Updatecode
		sql.Query( "UPDATE rleveldb SET level = '"..pl:GetNWInt("level").."' WHERE userid = '"..userid.."'" )
		sql.Query( "UPDATE rleveldb SET credit = '"..pl:GetNWInt("credits").."' WHERE userid = '"..userid.."'" )
		sql.Query( "UPDATE rleveldb SET xp = '"..pl:GetNWInt("xp").."' WHERE userid = '"..userid.."'" )
	else
		Msg("Sorry player dont EXISTS\n")
	end
	end)

end

function DeletePlayerInfo( pl , userid )
	if(pl:IsValid() ) then
		if( PlayerExists( userid ) == true) then
		pl:ChatPrint("Your Datas was delete by ADMIN... sorry for nothing")
		sql.Query( "DELETE FROM rleveldb ' WHERE userid = '"..userid.."'" )
		else
		// player Datensatz exestiert nicht

		end
	else
		// delete ohne MSG
		sql.Query( "DELETE FROM rleveldb ' WHERE userid = '"..userid.."'" )
	end
end


function Log( attacker , victim )
date = tostring( os.date() )
if( !file.Exists("RLevel/Log.txt","DATA") ) then
	file.Write("RLevel/Log.txt","LOG\n")
end
if( file.Exists("RLevel/Log.txt","DATA") ) then
	local filetext = file.Read("RLevel/Log.txt")
	file.Write("RLevel/Log.txt",""..filetext.."\n [ "..date.." ] Player: "..attacker:GetName().." killed "..victim:GetName().." !\n")
	end
end

function Top10Player( pl , tbl )

end

Msg("database was loaded\n")